package com.yanfan.ccapicode.service;

import com.yanfan.ccapicode.enums.ThirdPartyCloudEnum;
import com.yanfan.ccapicode.handler.action.AbstractCloudCloudHandler;
import com.yanfan.ccapicode.handler.factory.CloudCloudHandlerFactory;
import org.springframework.stereotype.Service;

/**
 * :)
 *  服务调度入口
 */
@Service
public class ThirdPartyPortalServiceImpl implements ThirdPartyPortalService {

    private final CloudCloudHandlerFactory cloudCloudHandlerFactory;

    public ThirdPartyPortalServiceImpl(CloudCloudHandlerFactory cloudCloudHandlerFactory) {
        this.cloudCloudHandlerFactory = cloudCloudHandlerFactory;
    }

    @Override
    public String portal(String request, ThirdPartyCloudEnum cloud) {
        AbstractCloudCloudHandler strategy = cloudCloudHandlerFactory.getStrategy(cloud.name(), AbstractCloudCloudHandler.class);
        return strategy.action(request);
    }
}
